//
//  LGShareSDK.m
//  ShareDemo
//
//  Created by Li Zhiping on 13-11-20.
//  Copyright (c) 2013年 Li Zhiping. All rights reserved.
//

#import "LGShareSDK.h"
#import "LGShareAccount.h"
#import "LGSinaAccount.h"
#import "LGSinaShare.h"

@interface LGShareSDK ()

@property (strong, nonatomic)LGShareContent *shareContent;

@end

@implementation LGShareSDK

+ (LGShareSDK *)sharedInstance{
    static dispatch_once_t pred = 0;
    __strong static id _sharedObject = nil;
    dispatch_once(&pred, ^{
        _sharedObject = [[self alloc] init]; // or some other init method
    });
    return _sharedObject;
}

+ (void)registerSinaApp:(NSString *)appKey
            redirectURI:(NSString *)url{
    [LGSinaShare registerApp:appKey redirectURI:url];
}

+ (BOOL)handleOpenURL:(NSURL *)url
           wxDelegate:(id)delegate{
    [LGSinaShare handleOpenURL:url];
    return YES;
}

//构建一个分享实例
+ (LGShareContent *)shareContent:(NSString *)content
               image:(UIImage *)image
                 url:(NSString *)url
  locationCoordinate:(LGLocationCoordinate2D *)locationCoordinate{
    
    LGShareSDK *shareSDK = [LGShareSDK sharedInstance];
    LGShareContent *shareContent = [LGShareContent instance];
    shareContent.content = content;
    shareContent.image = image;
    shareContent.url = url;
    shareContent.locationCoordinate = locationCoordinate;
    
    //保存需要分享的对象
    shareSDK.shareContent = shareContent;
    return [LGShareContent instance];
}

+ (void)sendWeiBoMessage{
    [LGSinaShare shareContent:[self sharedInstance].shareContent complete:nil];
}

@end
